<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="css/swiper.css">
    <script src="js/vue.js"></script>
</head>

<body>

    <div id="box">
        {{msg}}
        <button @click="handleClick">child</button>
        <child v-if="flag">销毁</child>
    </div>
    <script>
        Vue.component("child", {
            template: `<div>child</div>`,
            mounted() {
                window.onresize = function() {
                    console.log("哈哈")
                }
            },
            beforeDestroy() {
                console.log("beforeDestroy")
            },
            destroyed() { 
                console.log("destroyed")
                window.onresize = null
            }
        })
        var vm = new Vue({
            el: "#box",
            data: {
                msg: "hello",
                flag: true
            },
            methods: {
                handleClick() {
                    this.msg = "更新了"
                }
            },
            beforeCreate() {
                console.log("beforcreade", this.msg)
            },
            created() {
                console.log("created", this.msg + "111")
            },
            beforeMount() {
                console.log("beforeMount", this.msg + "222")
            },
            mounted() {
                console.log("mounted", this.msg + "333")
                this.$nextTick(function() {})
            },
            beforeUpdate() {
                console.log("beforeUpdate", this.msg + "444")
            },
            updated() {
                console.log("updated", this.msg + "555")
                this.$nextTick(function() {
                })
            }
        })
    </script>
</body>

</html>